import { baseData } from '../base.ts'
import {
  getDynamicComponentList
} from '@/api/url'
import Mock from 'mockjs'

// 获取所有动态组件
const dynamicComponentList = [`<template>
  <div>
    <p>我是远程组件</p>
    <p>
      当前远程组件count值为:<span class="count">{{ count }}</span>
    </p>
    <a-button @click="count++">添加</a-button>
  </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
const count = ref(0);
</script>

<style scoped>
.count {
  color: red;
}
</style>`]

Mock.mock(RegExp(getDynamicComponentList), 'get', function () {
  return Mock.mock({
    ...baseData,
    totalSize: dynamicComponentList.length,
    data: dynamicComponentList,
  })
})